<template>
	<view class="page_t">
		<pageheader :setting="settingdata"></pageheader>
		<go-top :scrollTop="scrollTop"></go-top>
		<block v-for="(item,index) in list" :key="index">
			<text class="timeline">{{item.content.createtime}}</text>
			<view class="notice">
				<view class="noticeTitle">{{item.content.title}}</view>
				<view class="noticeContent">{{item.content.content}}</view>
			</view>
		</block>
		<view class="not_more" v-if="list.length<1">
			<image src="../static/img/wxiaoxi.png" mode="widthFix"></image>
			<view class="text">暂无消息</view>
		</view>
		<view class="nomore" v-if="nomore&&list.length>0">—— · 没有更多了 · ——</view>
	</view>
</template>

<script>
	var _this, $paginator;
	export default {
		data() {
			return {
				settingdata: {
					name: '平台通知',
					bgColor: '#fff',
					titleColor: '#000000',
					showNav: true,
					showTypes: 0,
					position: "stationotice"
				},
				list: [],
				nomore: false,
				// 回到头部按钮距离
				scrollTop: 0,
			}
		},
		onLoad(e) {
			_this = this
			$paginator = new _this.$paginator(_this.$api)
			_this.getdata(true)
		},
		//监听页面滚动
		onPageScroll(res) {
			this.scrollTop = res.scrollTop
		},
		//下拉刷新
		onPullDownRefresh() {
			$paginator = new _this.$paginator(_this.$api)
			_this.getdata(true)
		},
		onReachBottom: function() {
			$paginator.nextPager(() => {
				_this.getdata()
			})
		},
		methods: {
			getdata: function(firstLoad = false) {
				$paginator.getData('ordmessagelist', {type:1}, (data) => {
					if (firstLoad) {
						_this.list = data.list ? data.list : []
					} else {
						_this.list = _this.list.concat(data.list)
					}
					_this.nomore = data.nomore
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page_t {
		min-height: 100vh;
		background-color: #f2f2f2;
		display: flex;
		flex-direction: column;
		align-items: center;

		.timeline {
			margin-top: 37rpx;
			color: #999999;
			font-size: 24rpx;
		}

		.notice {
			margin-top: 25rpx;
			width: 700rpx;
			padding: 30rpx 46rpx 52rpx 35rpx;
			display: flex;
			flex-direction: column;
			border-radius: 5rpx;
			background-color: #fff;

			.noticeTitle {
				color: #333333;
				font-size: 28rpx;
			}

			.noticeContent {
				margin-top: 22rpx;
				color: #999999;
				font-size: 26rpx;
			}
		}
	}
</style>
